package org.xlp.db.utils;

import org.xlp.db.tableoption.xlpenum.DBType;
import org.xlp.utils.XLPStringUtil;

/**
 * Description: 获取数据库类型工具类
 * <br/>date: 2024/1/15 15:51
 *
 * @version 1.0
 * @author: xlp
 */
public class DBTypeUtils {
    private static DBType dbType;

    /**
     * 获取数据库类型
     * @return
     */
    public static DBType getDbType(){
        if (dbType == null){
            String databaseProductName = XLPDBUtil.getDatabaseProductName();
            if (!XLPStringUtil.isEmpty(databaseProductName)){
                String lowerCase = databaseProductName.toLowerCase();
                if (lowerCase.contains("mysql")) return DBType.MYSQL_DB;
                if (lowerCase.contains("oracle")) return DBType.ORACLE_DB;
            }
        }
        return dbType;
    }
}
